package 寒假刷题;

public class 反转单词前缀 {
    public String reversePrefix(String word, char ch) {
        StringBuilder builder = new StringBuilder();
        int index = word.indexOf(ch);
        if (index < 0) {
            return word;
        }
        StringBuilder sb = new StringBuilder(word.substring(0, index + 1));
        sb.reverse().append(word.substring(index + 1));
        return sb.toString();
    }
}
